package com.ruoyi.system.controller;

import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysPushMoney;
import com.ruoyi.system.service.ISysPushMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 提成Controller
 * 
 * @author paul
 * @date 2023-06-25
 */
@RestController
@RequestMapping("/money")
public class SysPushMoneyController extends BaseController
{
    @Autowired
    private ISysPushMoneyService sysPushMoneyService;

    /**
     * 查询提成列表
     */
//    @PreAuthorize("@ss.hasPermi('system:money:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysPushMoney sysPushMoney)
    {
        startPage();
        List<SysPushMoney> list = sysPushMoneyService.selectSysPushMoneyList(sysPushMoney);
        return getDataTable(list);
    }

    /**
     * 导出提成列表
     */
//    @PreAuthorize("@ss.hasPermi('system:money:export')")
    @Log(title = "提成", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPushMoney sysPushMoney)
    {
        List<SysPushMoney> list = sysPushMoneyService.selectSysPushMoneyList(sysPushMoney);
        ExcelUtil<SysPushMoney> util = new ExcelUtil<SysPushMoney>(SysPushMoney.class);
        util.exportExcel(response, list, "提成数据");
    }

    /**
     * 获取提成详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:money:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysPushMoneyService.selectSysPushMoneyById(id));
    }

    /**
     * 新增提成
     */
//    @PreAuthorize("@ss.hasPermi('system:money:add')")
    @Log(title = "提成", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPushMoney sysPushMoney)
    {
        return toAjax(sysPushMoneyService.insertSysPushMoney(sysPushMoney));
    }

    /**
     * 修改提成
     */
//    @PreAuthorize("@ss.hasPermi('system:money:edit')")
    @Log(title = "提成", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysPushMoney sysPushMoney)
    {
        return toAjax(sysPushMoneyService.updateSysPushMoney(sysPushMoney));
    }

    /**
     * 删除提成
     */
//    @PreAuthorize("@ss.hasPermi('system:money:remove')")
    @Log(title = "提成", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysPushMoneyService.deleteSysPushMoneyByIds(ids));
    }
}
